package cn.lingyangwl.agile.system.manager;

import cn.lingyangwl.agile.system.mapper.SysUserRoleMapper;
import cn.lingyangwl.agile.system.model.entity.SysUserRole;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author shenguangyang
 */
@Service
public class SysUserRoleManager extends ServiceImpl<SysUserRoleMapper, SysUserRole> {
    public List<Long> listUserIdsByRoleId(Long roleId) {
        LambdaQueryWrapper<SysUserRole> lqw = SysUserRole.lqw().eq(SysUserRole::getRoleId, roleId);
        return this.list(lqw).stream().map(SysUserRole::getUserId).distinct().collect(Collectors.toList());
    }
}
